import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

// 重写push方法，防抖
let originPush = VueRouter.prototype.push
//第一个形参：路由跳转的配置对象（query|params）
//第二个参数：undefined|箭头函数（成功的回调）
//第三个参数:undefined|箭头函数（失败的回调）
VueRouter.prototype.push = function (location, resolve, reject) {
  if (resolve && reject) {
    originPush.call(this, location, resolve, reject)
  } else {
    originPush.call(this, location, () => { }, () => { })
  }
}

const routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('@/views/Recommendation.vue')
  },
  // {
  //   path: '/about',
  //   name: 'about',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: {
  //     default:HomeView,
  //     content: () => import('../views/try.vue')
  //   }
  // }
  {
    path: '/songDetail',
    name: 'songDetail',
    component: () => import('@/views/SongsDetail'),
    children: [
      {
        path: 'songList',
        component: () => import('@/views/SongsDetail/songList.vue')
      },
      {
        path: 'comments',
        component: () => import('@/views/SongsDetail/comments.vue')
      },
      {
        path:'collectors',
        component:()=>import('@/views/SongsDetail/collectors.vue')
      }
    ]
  },

  // 歌词路由
  {
    path:'/Lyrics',
    component:()=>import('@/views/Lyrics.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
